<template>
    <div class="age">
        <div class="title">
            <p>年龄比例</p>
            <img src="../../images/dataScreen-title.png" alt="">
        </div>
        <!-- echarts -->
        <div class="charts" ref="charts"></div>
    </div>
</template>

<script lang="ts" setup>
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
const charts = ref()
onMounted(() => {
    const myChart = echarts.init(charts.value)
    myChart.setOption({
        tooltip: {
            trigger: 'item'
        },
        // 图例组件方向设置
        legend: {
            top: '40px',
            right: '10px',
            orient: 'vertical',
            textStyle: {
                fontSize: 12,
                color: '#fff'
            }
        },
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: true,
                    position: 'inside',
                    color: '#fff',
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 10,
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                // color: ['#0081ff', '#00c2ff', '#00e4ff', '#00ffea', '#00ff9f'],
                data: [
                    { value: 1048, name: 'Search Engine' },
                    { value: 735, name: 'Direct' },
                    { value: 580, name: 'Email' },
                    { value: 484, name: 'Union Ads' },
                    { value: 300, name: 'Video Ads' }
                ]
            }
        ],
        // 调整图形位置
        grid: {
            left: 0,
            right: 0,
            top: 0,
            bottom: 0
        }
        // 
    })
})
</script>

<style lang="scss" scoped>
.age {
    height: 100%;
    width: 100%;
    background: url(../../images/dataScreen-main-cb.png) no-repeat;
    background-size: 100% 100%;

    .title {
        margin-left: 20px;

        p {
            font-size: 20px;
            color: #fff;
        }
    }

    .charts {
        width: 100%;
        height: 260px;
        margin-top: 30px;
    }
}
</style>